home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Languguage OS 2
/
Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO
/
language
/
pcpil
/
sample4.pil
< prev
next >
Wrap
Text File
|
1979-12-31
|
4KB
|
85 lines
T:Example of calling assembler
T:language from a PILOT program.
T:This is for assembler language
T:programmers only.
T:
R:
R: The following is the X.LST file as created by the ASM program when the
R: subroutine is assembled with the IBM assembler.
R:
R: PROG SEGMENT BYTE PUBLIC 'PROG'
R: TEST PROC FAR
R: ASSUME CS:PROG,DS:PROG
R: ORG 0 ;start at 0
R: 0000 EB 0E JMP short GO ;skip parm area
R: ; Above here should be exactly as shown.
R: ; Next, put in up to 125 bytes of parm area.
R: 0002 41 42 PARM1: DB 'AB' ;parm from pilot prog
R: 0004 43 44 PARM2: DB 'CD' ;parm to pilot prog
R: 0006 45 46 DB 'EFGHIJKLMN' ;filler (unused here)
R: ; here is the subroutine proper
R: 0010 A1 0002 GO: MOV AX,PARM1 ;take input parm
R: 0013 A3 0004 MOV PARM2,AX ;move it to output parm
R: ; below here shoud be exactly as shown
R: 0016 CB RET ;far return to pilot
R: TEST ENDP
R: PROG ENDS
R: END
R:
R: If the above program were stored in file X.ASM then it could be prepared
R: for use with PILOT as follows:
R: ASM X (push return to 3 prompts from assembler)
R: LINK X (push return to 3 prompts from linker)
R: EXE2BIN X
R: The result is in file X.BIN and could be loaded by a pilot program
R: by the sequence dx:a$(30)
R: fx:X.BIN
R: fi:0,a$
R: Alternatively, the soubroutine could be built in the string by the pilot
R: program as shown below.
R:
R: next line creates string to hold the subroutine
dx:a$(30)
r: next line puts in the JMP and fills the parm area with data
c:a$=chr(235)!!chr(14)!!"abcdefghijklmn"
r: next line fills in the rest of the subroutine
c:a$=a$!!chr(161)!!chr(2)!!chr(01)!!chr(163)!!chr(4)!!chr(1)!!chr(203)
r: next lines insert the zeros because they can't be
r: concatenated the way PILOT handles strings.
c:a$(22)=chr(0)
c:a$(19)=chr(0)
r: next line shows the parm area to the user
t:#(a$(3,14))
T:
T:Push return and watch what happens to
T:the c and d in the above line.
r: next line waits for return key
a:
r: next line calls the asm subr
v:a$
r: next line shows user the changed parameter bytes
t:#(a$(3,14))
T:
T:If you are interested in assembler
T:lanugage subroutines, you can
T:study this program to see how
T:it can be done from PILOT.
r:
R: the soubroutine could be saved on disk for use later via
R: FX:XSUB
R: FO:0,a$
R: it could be read back in later by another program via
R: DX:a$(30)
R: FX:XSUB
R: FI:0,a$
R: Notice that the subroutine assumes that both the code and data
R: segments start at the start of the program; thus it is assembled
R: for offset 0. Also notice the technique of leaving some bytes
R: toward the start of the subroutine to allow for passing of data
R: to and from the subroutine. You could leave any number of bytes
R: in this manner. To pass data to the subroutine just set these bytes
R: by a statement like C:a$(3,4)="EASY" Then to get results
R: back from the subroutine have it store the result in the same
R: area and access it from the program via C:x$=a$(3,4)